package com.zhuiYun.project.api.handworkdiy.controller;

import com.zhuiYun.project.api.handworkdiy.service.HandworkService;
import com.zhuiYun.project.common.errorCode.CommonException;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName HandworkDiy
 * @Description TODO
 * @Author lzy
 * @Date 2023/4/5 17:52
 **/
@RestController
@RequestMapping("/handworkDiy")
@Api(tags = "手工店模块")
@Slf4j
@CrossOrigin
public class HandworkDiyContorller {

    @Autowired
    HandworkService handworkService;

    /**
     * @param ids
     * @Description 获取手工diy信息列表
     * @Author lzy
     * @Date 2023/4/5 18:09
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyListByIds")
    @ApiOperation(value = "根据diyids数组查询diy商品")
    public CommonResult getHandworkDiyListByIds(String ids) throws CommonException {
        return handworkService.getHandworkDiyListByIds(ids);
    }

    /**
     * @param
     * @Author kdj
     * @Description 查询DIY的特价商品方法
     * @Date 2023/4/5 19:15
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyListByOffer")
    @ApiOperation(value = "查询DIY的特价商品方法")
    public CommonResult getHandworkDiyListByOffer() {
        log.info("查询DIY的特价商品");
        return handworkService.getHandworkDiyListByOffer();
    }

    /**
     * @param
     * @Author kdj
     * @Description 查询DIY的特色商品方法
     * @Date 2023/4/5 21:02
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyListByCharacteristic")
    @ApiOperation(value = "查询DIY的特色商品方法")
    public CommonResult getHandworkDiyListByCharacteristic() {
        log.info("查询DIY的特色商品方法");
        return handworkService.getHandworkDiyListByCharacteristic();
    }

    /**
     * @param
     * @Author kdj
     * @Description 查询DIY的类型列表
     * @Date 2023/4/6 12:01
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyTypeList")
    @ApiOperation(value = "查询DIY的类型列表")
    public CommonResult getHandworkDiyTypeList() {
        log.info("查询DIY的类型列表");
        return handworkService.getHandworkDiyTypeList();
    }
    /**
     * @param typeId
     * @param queryDiyName
     * @param minPrice
     * @param maxPrice
     * @param orderValue
     * @param pageRequest
     * @Author kdj
     * @Description 根据Pc页面条件查询Diy商品列表
     * @Date 2023/4/7 11:48
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyListByPageParams")
    @ApiOperation(value = "根据Pc页面条件查询Diy商品列表")
    public CommonResult getHandworkDiyListByPageParams(Integer typeId, String queryDiyName, @RequestParam(required = false) Integer minPrice,
                                                       @RequestParam(required = false) Integer maxPrice, String orderValue,
                                                       PageRequest pageRequest) {
        log.info("根据Pc页面条件查询Diy商品列表");
        return handworkService.getHandworkDiyListByPageParams(typeId, queryDiyName, minPrice, maxPrice, orderValue, pageRequest);
    }

    /**
     * @param id
     * @Author kdj
     * @Description 根据diyid获取 DIY商品信息
     * @Date 2023/4/7 14:38
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getHandworkDiyById")
    @ApiOperation(value = "根据diyid获取 DIY商品信息")
    public CommonResult getHandworkDiyById(Integer id) {
        log.info("根据diyid获取 DIY商品信息");
        return handworkService.getHandworkDiyById(id);
    }

    /**
    * @Author kdj
    * @Description 根据diyid计算diy商品评论总数量
    * @Date 2023/4/7 17:07
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param id
    */
    @GetMapping("/calculateTheTotalNumberOfComments")
    @ApiOperation(value = "根据diyid计算diy商品评论总数量")
    public CommonResult calculateTheTotalNumberOfComments(Integer id) {
        log.info("根据diyid计算diy商品评论总数量");
        return handworkService.calculateTheTotalNumberOfComments(id);
    }
    /**
     * @Author kdj
     * @Description 根据diyid查看diy商品所有评论
     * @Date 2023/4/7 17:07
     * @Return com.zhuiYun.project.common.response.CommonResult
     * @param id
     * @param pageRequest
     */
    @GetMapping("/queryAllComments")
    @ApiOperation(value = "根据diyid查看diy商品所有评论")
    public CommonResult queryAllComments(Integer id, PageRequest pageRequest) {
        log.info("根据diyid计算diy商品评论总数量");
        return handworkService.queryAllComments(id,pageRequest);
    }
    /**
     *
     * @Author lzk
     * @Description 查询diy所有信息
     * @date 2023/4/12 15:18
     * Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/queryDIYInformation")
    @ApiOperation(value = "查询diy所有信息")
    public CommonResult queryDIYInformation() {
        log.info("查询diy所有信息");
        return handworkService.queryDIYInformation();
    }

    /**
    * @Author gpd
    * @Description 搜索栏模糊查（uniapp首页搜索栏）
    * @Date 2023-04-13 上午 08:45
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param selectValue
    */
    @GetMapping("/selectCommodity")
    public CommonResult selectCommodity(String selectValue){
        return CommonResult.ok(handworkService.selectCommodity(selectValue));
    }
}
